/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import sys.DB;

/**
 *
 * @author PC-Vanny
 */
public class BrandModel extends DB {

    //Connection connection = null; // obj of class 'sql.Connetion' used to connect database from server site
    //Statement st;
    //ResultSet rs;                 // obj of class 'sql.ResultSet'  , ResultSet is abstract method that call from class IDb , that Class DB implements from IDB
    //ArrayList<Object> data; // ArrayList used to store data from resultSet  (mean that, ResultsSet got data from sever --> arrayList get data from ResultSet --> move data to table ) 

//    public BrandModel() {  // constractor , why we create connection in constractor ? cus the begining of proscess in class is constractor 
//        //  DB b=  new DB();
//        try {
//            Class.forName("com.mysql.jdbc.Driver"); // includ driver 
//            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/javapos", "root", "");  // conection
//        } catch (ClassNotFoundException | SQLException ex) {
//            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);   // 
//        }
//    }

    public ResultSet SearchBrand(String sql) {

        try {
            super.st = super.connection.createStatement();

            rs = st.executeQuery(sql);
        } catch (SQLException ex) {
            Logger.getLogger(BrandModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

}
